#define DEBUG
#include <cstdio>
#define INF 0x7fffffffffff
#define MAXN 100000

using namespace std;

long long min(long long a, long long b) {
  return a<b ? a : b;
}

long long max(long long a, long long b) {
  return a>b ? a : b;
}

int main() {
  freopen("a.in", "r", stdin);
  freopen("a_bf.out", "w", stdout);

  static long long f[MAXN+1], t[MAXN+1], a[MAXN+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%lld %lld", t+i, a+i);
  }

  for (int i=1; i<=n; i++) {
    f[i]=INF;
    int maxa=0;
    for (int j=i; j>0; j--) {
      maxa=max(maxa, a[j]);
      f[i] = min(f[i], max(t[i], f[j-1])+2*maxa);
    }
  }

  printf("%lld", f[n]);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
